<template>
    <div class="user-container">
        <!--  用户信息与资产卡片 -->
        <section class="user-info-card">
            <div class="user">
                <div class="user-info">
                    <img src="@/assets/messageImg/touxiang.png" alt="用户头像" class="avatar" />
                    <div class="user-name">租币当钱花</div>
                </div>
                <div class="rules"><van-icon name="question-o" />&nbsp;规则</div>
            </div>

            <div class="balance-container">
                <div class="balance">
                    <p>可用租币</p>
                    <div class="amount">{{ goldCoins }}</div>
                </div>
                <div class="earn-btn" @click="handleEarnBtnClick"></div>
            </div>

        </section>
        <!--  活动横幅 -->
        <section class="activity-banners">
            <div class="banner-scroll-container">
                <div class="banner-item bg-img-1"></div>
                <div class="banner-item bg-img-2"></div>
                <div class="banner-item bg-img-2"></div>
            </div>
        </section>
    </div>
</template>
<script lang="ts" setup>
import router from '@/router'
import { storeToRefs } from 'pinia'
import { useGoldCoinStore } from '@/stores/goldCoins';
const goldCoinStore = useGoldCoinStore()
const { goldCoins } = storeToRefs(goldCoinStore)
const handleEarnBtnClick = () => {
    router.push('/task');
};
</script>
<style lang="scss" scoped>
/* // 定义通用变量 */
$primary-orange: #ff6a00;
$light-gray-bg: #f7f8fa;

.user-container {
    position: relative;
    padding-bottom: 40px;
    .user-info-card {
        height: 146px;
        padding: 10px 16px;
        background: linear-gradient(138deg, #FF8A3C 0%, #FF611C 100%);
        border-radius: 0px 0px 0px 21px;

        .user {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-weight: 400;
            font-size: 12px;
            color: #FFFFFF;
            line-height: 12px;
            font-style: normal;

            .user-info {
                display: flex;
                align-items: center;

                .avatar {
                    width: 33px;
                    height: 33px;
                    border-radius: 50%;
                    background-color: #fff;
                    margin-right: 7px;
                }

                .user-name {
                    background-color: rgba(255, 255, 255, 0.15);
                    padding: 4px 5px;
                    font-size: 12px;
                }
            }

        }

        .balance-container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 16px;

            .balance {
                p {
                    font-weight: 400;
                    font-size: 12px;
                    color: #FFFFFF;
                    line-height: 12px;
                    text-align: left;
                    font-style: normal;
                }

                .amount {
                    font-family: DINAlternate, DINAlternate;
                    font-weight: bold;
                    font-size: 4.976vh;
                    color: #FFFFFF;
                    line-height: 5.924vh;
                    text-align: left;
                    font-style: normal;
                }
            }

            .earn-btn {
                width: 135px;
                height: 63px;
                background-size: 100% 100%;
                background-repeat: no-repeat;
                background-image: url('@/assets/shopStoreImg/编组 4@2x.png');
            }


        }
    }

    .activity-banners {
        position: absolute;
        top:137px;
        height: 72px;
        width: 100%;
        overflow: hidden;
        box-sizing: border-box;

        .banner-scroll-container {
            display: flex;
            width: 100%;
            height: 100%;
            overflow-x: auto;
            overflow-y: hidden;
            -webkit-overflow-scrolling: touch;
            /* 为iOS设备提供平滑滚动效果 */

            /* 隐藏滚动条但保持功能 */
            &::-webkit-scrollbar {
                display: none;
            }

            -ms-overflow-style: none;
            scrollbar-width: none;

            .banner-item {
                flex-shrink: 0;
                width: 139px;
                height: 8.13vh;
                border-radius: 8px;
                margin-right: 12px;
                background-size: 141px 8.37vh;
                background-repeat: no-repeat;
                background-position: center;
            }

            .bg-img-1 {
                margin-left: 25px;
                background-image: url('@/assets/shopStoreImg/wechat_2025-09-27_172628_419.png');
            }

            .bg-img-2 {
                background-image: url('@/assets/shopStoreImg/wechat_2025-09-27_172749_225.png');
            }
        }
    }
}
</style>